var e = require;
var t = module;
var n = exports;
("use strict");
var o,
  i =
    (this && this.__extends) ||
    ((o = function (e, t) {
      return (o =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (e, t) {
            e.__proto__ = t;
          }) ||
        function (e, t) {
          for (var n in t)
            Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
        })(e, t);
    }),
      function (e, t) {
        function n() {
          this.constructor = e;
        }
        o(e, t),
          (e.prototype =
            null === t
              ? Object.create(t)
              : ((n.prototype = t.prototype), new n()));
      }),
  r =
    (this && this.__decorate) ||
    function (e, t, n, o) {
      var i,
        r = arguments.length,
        y =
          r < 3
            ? t
            : null === o
              ? (o = Object.getOwnPropertyDescriptor(t, n))
              : o;
      if ("object" == typeof Reflect && "function" == typeof Reflect.decorate)
        y = Reflect.decorate(e, t, n, o);
      else
        for (var a = e.length - 1; 0 <= a; a--)
          (i = e[a]) &&
            (y = (r < 3 ? i(y) : 3 < r ? i(t, n, y) : i(t, n)) || y);
      return 3 < r && y && Object.defineProperty(t, n, y), y;
    };
Object.defineProperty(n, "__esModule", { value: !0 });
var y,
  a = e("BaseUI"),
  s = e("ConfigConst"),
  c = e("EventConst"),
  x = e("PlatformConst"),
  l = e("SceneConst"),
  h = e("UserConst"),
  d = e("ConfigManager"),
  u = e("EventManager"),
  f = e("PlatformManager"),
  p = e("PopupManager"),
  g = e("SceneManager"),
  m = e("TipManager"),
  v = e("UserManager"),
  b = e("XMADUtils"),
  t = cc._decorator,
  e = t.ccclass,
  e =
    (t.property,
      (y = a.default),
      i(_, y),
      (_.prototype.onLoad = function () {
        y.prototype.onLoad.call(this),
          (this.text = this.dict.text.getComponent(cc.Label)),
          this.addBtnOn("nextBtn", this.clickNext, this),
          // cc.game.on("clickNext", this.clickNext, this),
          this.addBtnOn("videoBtn", this.clickVideo, this),
          this.addBtnOn("shareBtn", this.clickShare, this),
          this.addBtnOn("homeBtn", this.clickHome, this),
          this.addBtnOn("restartBtn", this.clickRestart, this),
          this.initView();
      }),
      (_.prototype.onEnable = function () {
        // window.showIn();
        // window.__prv.doAction(1, ['oppo']);
        window.__prv.doAction(1, ['oppo']);
        window.__prv.doAction(1, ['vivo']);
        window.__prv.doAction(6, ['ks3']);
        window.__prv.doAction(1, ["ks5"]);
        window.__prv.doAction("成功页面后弹宝箱连点", ["ks5"]);
        window.__prv.doAction('二级界面弹出插屏', ['hw']);
        // f.Platform.is(x.EPlatform.XIAOMI_ANDROID)
        //   ? (b.XMAD.showLargeFeed(), b.XMAD.showInterstitialFeed_result())
        //   : f.Platform.showBanner();

      }),
      (_.prototype.onDisable = function () {
        f.Platform.is(x.EPlatform.XIAOMI_ANDROID) && b.XMAD.removeLargePicFeed(),
          f.Platform.hideBanner();
      }),
      (_.prototype.initView = function () {
        var n = this,
          o = v.User.getTempData(h.TempData.CURRENT_LEVEL_ID);
        d.Config.get(s.ConfigConst.RESULT).then(function (e) {
          for (var t = 0; t < e.length; t++)
            e[t].stageID == o && (n.text.string = e[t].resultText);
        }),
          (this.dict.shareBtn.active = !1),
          f.Platform.getConfig().hasRecord && (this.dict.shareBtn.active = !0),
          cc.game.emit("gamelog", "page007");
        var e = v.User.getTempData(h.TempData.CURRENT_LEVEL),
          t = v.User.getTempData(h.TempData.CURRENT_MODE);
        e <= 100 && cc.game.emit("gamelog", "Level_Win_" + t + "_" + e),
          (this.dict.screenshot.getComponent(cc.Sprite).spriteFrame =
            window.screenShotPicture);
      }),
      (_.prototype.clickNext = async function () {
        cc.game.emit("gamelog", "btn022"),
          console.log(this.dict.icon.active)
        console.log(window.adp2);
        if (this.dict.icon.active) {
          // // 判断p2的值
          // await this.clickVideos()
          // this.nextCb();
          console.error("有视频标识");
          var me = this;
          if (window.__prv.getChannel() == 'ks1') {
            if (window.__prv.getCtrl('p2')) {
              window.__prv.showVideo(function () {
                me.nextCb();
              });
            } else {
              me.nextCb();
            }
          } else {
            window.__prv.showVideo(function () {
              me.nextCb();
            });
          }

        } else {
          console.error("没有视频标识");
          this.nextCb();
          // f.Platform.is(x.EPlatform.XIAOMI_ANDROID) &&
          //   b.XMAD.showInterstitialFeed();
        }
        // // 获得当前关卡
        // // if(window.adp2[0])
        // // window["adP2"][0]
        // var e = v.User.getTempData(h.TempData.CURRENT_LEVEL)
        // console.log('start1')
        // let scene=['game_center','lbs','im','search','detail_link','detail_tag','campaign','sidebar_miniprogram','profile','retention_apk','retention_desk_ios']
        // let boo=true
        // let boo1=false
        // for (let element of scene) {
        //   if (element === cc.sys.localStorage.getItem('sceneFrom')) {
        //       boo=false
        //       break;
        //   }
        //   console.log(element);
        // }
        // let n1=Math.random()*100
        // if(window.adp3>=n1){
        //   boo1=true

        // }
        // if(window.adp3==0) {boo1=false}
        // console.log('boo1',boo1)
        // console.log('boo',boo)
        // if(e>=window.adp2[0]&&(e-window.adp2[0])%[window.adp2[1]+1]==0&&boo&&boo1){
        //   // 开始强制  强制次数 
        //   console.log('start2')

        //   await this.clickVideos()
        //   this.total+=1;
        //   if(this.total>=window.adp2[2]){
        //     this.total=0
        //     // 观看了所有强制视频   进入下一关
        //     this.nextCb()
        //   }
        // }else{
        //   console.log('start3')

        //   if(this.dict.icon.active){
        //     // 判断p2的值
        //     await this.clickVideos()
        //     this.nextCb();

        //   }else{
        //     await this.nextCb();
        //     // f.Platform.is(x.EPlatform.XIAOMI_ANDROID) &&
        //     //   b.XMAD.showInterstitialFeed();
        //   }
        // }

      }),
      (_.prototype.nextCb = function () {
        u.Event.emit(c.default.CLICK_NEXT), p.Popup.hide();

      }),
      (_.prototype.clickVideo = function () {
        console.error("win clickVideo");
        var t = this;
        cc.game.emit("gamelog", "btn023"),
          window.__prv.showVideo(function () {
            0 == 0 &&
              (cc.game.emit("gamelog", "rewarde_btn005"),
                (e = v.User.get(h.UserData.KEY)),
                console.log(h.UserData.KEY),

                v.User.set(h.UserData.KEY, e + 1),
                u.Event.emit(c.default.KEY_EFFECT)
                // t.nextCb()
              );
          });
      }),
      (_.prototype.clickVideos = function () {
        console.error("clickVideos");
        var t = this;
        cc.game.emit("gamelog", "btn023"),
          window.__prv.showVideo(function () {
            0 == 0 &&
              (cc.game.emit("gamelog", "rewarde_btn005"),
                (e = v.User.get(h.UserData.KEY)),
                console.log(h.UserData.KEY),

                v.User.set(h.UserData.KEY, e + 1),
                u.Event.emit(c.default.KEY_EFFECT)
                // t.nextCb()
              );
          });
      }),
      (_.prototype.lingqu = function () {
        var t = this;
        0 == e &&
          (
            (e = v.User.get(h.UserData.KEY)),

            v.User.set(h.UserData.KEY, e + 10),

            u.Event.emit(c.default.KEY_EFFECT),
            t.nextCb());
      }),
      (_.prototype.clickShare = function () {
        var t = this;
        f.Platform.shareRecordCap(function (e) {
          0 == e
            ? (m.Tip.show("分享录屏成功！"), t.nextCb())
            : -1 == e && m.Tip.show("录屏时间过短！");
        });
      }),
      (_.prototype.clickHome = function () {
        g.Scene.loadScene(l.SceneConst.MAIN);
      }),
      (_.prototype.clickRestart = function () {
        p.Popup.hide(), cc.game.emit("onRestartBtn");
      }),
      r([e], _));
function _() {
  var e = (null !== y && y.apply(this, arguments)) || this;
  return (e.text = null, e.total = 0), e;
}
n.default = e;
